#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 1e5 + 10;

int n;
int q[N];


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        cin >> n;
        for(int i = 1; i <= n; i ++) cin >> q[i];

        int n1 = 0, n2 = 0;
        for(int i = 1; i <= n; i ++){
            if(q[i] % 2){
                n1 ++;
            }else{
                n2 ++;
            }
        }

        cout << min(n - n1, n - n2) << '\n';
    }


    return 0;
}